package zerous.craft.entity;

import android.graphics.*;
import zerous.craft.*;

public class Player
{
	public int x,y;
	
	public int turnX=0,turnY=0;
	public int scrX,scrY;
	public boolean isVoid,turnL,turnR=true;
	
	int speed=1;
	public static int time=0;
	
	public static enum STATE
	{
		Idel,Jump,Left,Right
	}
	
	public static boolean isJump,isRight,isLeft,isDorp;
	
	public static STATE state = STATE.Idel;
	
	public Player(int x, int y)
	{
		this.x = x;
		this.y = y;
	}
	
	public void draw(Canvas c, Paint p)
	{
		switch(state)
		{
			case Jump:
				c.translate(turnX,turnY+=speed*10);
				time++;
				if(time == 8)
				{
					isVoid = true;
					time=0;
				}
				if(turnL)
				{
					c.drawBitmap(Assets.Fplayer,scrX,scrY-10,p);
				}
				if(turnR)
				{
					c.drawBitmap(Assets.player,scrX,scrY-10,p);
				}
				break;
			case Left:
				c.translate(turnX+=speed*2,turnY-=speed*2);
				c.drawBitmap(Assets.Fplayer,scrX,scrY,p);
				turnR = false;
				turnL = true;
				break;
			case Right:
				c.translate(turnX-=speed*2,turnY-=speed*2);
				c.drawBitmap(Assets.player,scrX,scrY,p);
				turnR = true;
				turnL = false;
				break;
			case Idel:
				c.translate(turnX,turnY-=speed*4);
				if(turnL)
				{
					c.drawBitmap(Assets.Fplayer,scrX,scrY,p);
				}
				if(turnR)
				{
					c.drawBitmap(Assets.player,scrX,scrY,p);
				}
				
		}
		if(isVoid)
		{
			state = STATE.Idel;
		}
		scrX=(-turnX+GameRenderer.scrW/2);
		scrY=(-turnY+GameRenderer.scrH/2);
	}
}
